package com.zsc.springcloud.controller;

import com.zsc.springcloud.AccessLimiter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class Controller {

    @Autowired
    private AccessLimiter  accessLimiter;

    @GetMapping("test")
    public String test(){
        accessLimiter.limitAccess("ratelimiter-test",1);
        return "success";
    }


    @GetMapping("annotationTest")
    @com.zsc.springcloud.annotation.AccessLimiter(limit = 1)
    public String annotationTest(){
        log.info("进入annotationTest方法");
        return "success";
    }
}
